import { _decorator, Component, Node, EditBox } from "cc";
import { getGlobal, MyGlobal } from "../Global";
const { ccclass, property } = _decorator;
const names = [
  "上官",
  "欧阳",
  "东方",
  "端木",
  "独孤",
  "司马",
  "南宫",
  "夏侯",
  "诸葛",
  "皇甫",
  "长孙",
  "宇文",
  "轩辕",
  "东郭",
  "子车",
  "东阳",
  "子言",
  "西门",
  "长江",
  "北向",
];

const names2 = [
  "雀圣",
  "赌侠",
  "赌圣",
  "稳赢",
  "不输",
  "好运",
  "自摸",
  "有钱",
  "土豪",
];
@ccclass("Createrole")
export class Createrole extends Component {
  @property(EditBox)
  inputName: EditBox;
  @property(MyGlobal)
  g: MyGlobal;
  start() {
    this.g = getGlobal();
  }
  resetName() {
    var idx = Math.floor(Math.random() * (names.length - 1));
    var idx2 = Math.floor(Math.random() * (names2.length - 1));
    this.inputName.string = names[idx] + names2[idx2];
  }
  confirm() {
    let name = this.inputName.string;
    if (!name) {
      return;
    }
    this.g.userMgr.create(name);
  }
  update(deltaTime: number) {}
}
